﻿#ifndef PROPERTYVIEW_H
#define PROPERTYVIEW_H

//[
//{
//	"name":"Axes",
//	"label":["Length","Radius"],
//	"type":["float","float"],
//	"data":["1","0.01"]
//},
//{
//	"name":"Grid",
//	"label" : ["Cell Size","Cell Count","Grid Type","Grid Color"],
//	"type" : ["float","int","enum","color"] ,
//	"data" : ["1","10","XY;XZ;YZ;0","1;1;1"]
//}
//]


#include "export.h"
#include <QWidget>

#include "qttreepropertybrowser.h"
#include "qtpropertymanager.h"
#include "custommanager.h"
#include "qteditorfactory.h"

#include "common.h"

namespace EasyLib
{
	class API_EXPORT PropertyView :public QWidget
	{
		Q_OBJECT
	public:
		PropertyView(QWidget* parent = nullptr);
		virtual ~PropertyView();

		void clear();
		void setup(QVector<PropGroup> vGroup);

	signals:
		void signal_propertyInfo(QVector<PropGroup> vGroup);

	private:
		QtProperty* newProperty(PropGroup group, int idx);

		void intMngValueChanged(QtProperty* prop, const int value);
		void floatMngValueChanged(QtProperty* prop, const float value);
		void boolMngValueChanged(QtProperty* prop, const bool value);
		void strMngValueChanged(QtProperty* prop, const QString& value);
		void enumMngValueChanged(QtProperty* prop, const int value);
		void colorMngValueChanged(QtProperty* prop, const QColor& value);
		void vec3MngValueChanged(QtProperty* prop, const Vec3& value);

		QtTreePropertyBrowser* m_pBrowser;

		QtGroupPropertyManager* m_pGroupMng;
		QtStringPropertyManager* m_pStrMng;

		QtIntPropertyManager* m_pIntMngCanEdit;
		QtSpinBoxFactory* m_pIntFac;

		QtDoublePropertyManager* m_pFloatMngCanEdit;
		QtDoubleSpinBoxFactory* m_pFloatFac;

		QtBoolPropertyManager* m_pBoolMngCanEdit;
		QtCheckBoxFactory* m_pBoolFac;

		QtStringPropertyManager* m_pStrMngCanEdit;
		QtLineEditFactory* m_pStrFac;

		QtEnumPropertyManager* m_pEnumMngCanEdit;
		QtEnumEditorFactory* m_pEnumFac;

		QtColorPropertyManager* m_pColorMngCanEdit;
		QtColorEditorFactory* m_pColorFac;

		Vec3Manager* m_pVec3MngCanEdit;


		QVector<PropGroup>		m_vGroup;
	};
}
#endif 

